$(function(){
	dictionaryStart("model","121001");
	dictionaryStart("productionfactory","121002");
});

function add(){
	var devicename=$("#devicename").val();
	if(devicename==""){
		alert('设备名称为空');
		$("#devicename").focus();
		return;
	}
	/*if($("input[name='localcity']").val()==""){
		alert("所属地市为空");
		$("input[name='localcity']").focus();
		return;
	}
	if($("input[name='operationunit']").val()==""){
		alert("运维单位为空");
		$("input[name='operationunit']").focus();
		return;
	}
	if($("input[name='maintenanceteam']").val()==""){
		alert("维护单位为空");
		$("input[name='maintenanceteam']").focus();
		return;
	}
	if($("input[name='commissioningdate']").val()==""){
		alert("投运日期为空");
//		$("input[name='commissioningdate']").focus();
		return;
	}
	if($("input[name='equipmentowner']").val()==""){
		alert("设备主人为空");
		$("input[name='equipmentowner']").focus();
		return;
	}
	if($("input[name='assetnumber']").val()==""){
		alert("资产编号为空");
		$("input[name='assetnumber']").focus();
		return;
	}*/
	var list=$("#form").serialize();
	$.ajax({
		url : contextPath+"user/zydlzd/add",
		data : {data : list},
		type : "post",
		success : function(data){
			alert(data.msgDesc);
			if(data.opResult=="0"){
				location.href=contextPath+"user/z/zydlzdlist.jsp?deviceid="+deviceid+"&t="+new Date().getTime();
			}
		}
	});
}

function edite(){
	var devicename=$("#devicename").val();
	if(devicename==""){
		alert('设备名称为空');
		$("#devicename").focus();
		return;
	}
	/*if($("input[name='localcity']").val()==""){
		alert("所属地市为空");
		$("input[name='localcity']").focus();
		return;
	}
	if($("input[name='operationunit']").val()==""){
		alert("运维单位为空");
		$("input[name='operationunit']").focus();
		return;
	}
	if($("input[name='maintenanceteam']").val()==""){
		alert("维护单位为空");
		$("input[name='maintenanceteam']").focus();
		return;
	}
	if($("input[name='commissioningdate']").val()==""){
		alert("投运日期为空");
//		$("input[name='commissioningdate']").focus();
		return;
	}
	if($("input[name='equipmentowner']").val()==""){
		alert("设备主人为空");
		$("input[name='equipmentowner']").focus();
		return;
	}
	if($("input[name='assetnumber']").val()==""){
		alert("资产编号为空");
		$("input[name='assetnumber']").focus();
		return;
	}*/
	var list=$("#form").serialize();
	$.ajax({
		url : contextPath+"user/zydlzd/edite",
		data : {data : list},
		type : "post",
		success : function(data){
			alert(data.msgDesc);
			if(data.opResult=="0"){
				location.href=contextPath+"user/z/zydlzdlist.jsp?deviceid="+deviceid+"&t="+new Date().getTime();
			}
		}
	});
}

function setDefault(elementId,data){
	$('#'+elementId).val(data);
}